﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GBPVR.Public;
using GBPVRX2.UiSupport;
using System.Drawing;

namespace GBPVRLibrary.ControlLibrary
{
    public static class ExtensionMethods
    {
        public static void SetRectangle(this GBPVRUiElement Element, System.Drawing.RectangleF rect)
        {
            GuiElement.OriginalRectangles[Element] = rect;
            Element.SetRect(rect);
        }

        public static void SetTextureBounds(this GBPVRUiElement Element, PointF TopLeft, PointF TopRight, PointF BottomLeft, PointF BottomRight)
        {
            if (!GuiElement.RenderElements.ContainsKey(Element))
                GuiElement.RenderElements[Element] = new GuiElement.GBPVRUiElementAttributes(Element);
            GuiElement.GBPVRUiElementAttributes  o = GuiElement.RenderElements[Element];
            o.TextureBottomLeft = BottomLeft;
            o.TextureBottomRight= BottomRight;
            o.TextureTopLeft = TopLeft;
            o.TextureTopRight = TopRight;
        }

        public static void SetLocation(this UiStatic Element, System.Drawing.PointF Location)
        {
            Element.setLocation(Location);
            foreach (GBPVRUiElement element in Element.GetRenderList())
                GuiElement.OriginalRectangles[element] = element.rect;
        }
    }
}
